import Vue from 'vue'
import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/sso-login',
    component: () => import('@/views/login/login'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: {
        title: 'Dashboard',
        icon: 'dashboard'
      }
    }]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [
  {
    path: '/phone-users',
    component: Layout,
    name: 'PhoneUsers',
    meta: {
      title: '手机用户信息',
      icon: 'mobile',
      roles: ['SuperAdmin', 'Editor']
    },
    children: [
      {
        path: 'list',
        name: 'PhoneUsersList',
        component: () => import('@/views/users/phones'),
        meta: {
          title: '手机用户信息',
          breadcrumb: false,
          roles: ['SuperAdmin', 'Editor']
        }
      }
    ]
  },

  {
    path: '/all-users',
    component: Layout,
    name: 'AllUsers',
    meta: {
      title: '用户',
      icon: 'user',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: '/users',
        name: 'Users',
        component: () => import('@/views/users/index'),
        redirect: '/users/list?page=1',
        meta: {
          title: '用户列表',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'UsersList',
            component: () => import('@/views/users/list'),
            meta: {
              title: '用户列表',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'list/:id',
            name: 'UserShow',
            component: () => import('@/views/users/show'),
            meta: {
              title: '用户详情',
              activeMenu: '/users/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'UserEdit',
            component: () => import('@/views/users/edit'),
            meta: {
              title: '编辑用户',
              activeMenu: '/users/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/hcp-users',
        name: 'HcpUsers',
        component: () => import('@/views/hcps/index'),
        redirect: '/hcp-users/list?page=1',
        meta: {
          title: 'HCP',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'HcpUsersList',
            component: () => import('@/views/hcps/list'),
            meta: {
              title: 'HCP',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'list/:id',
            name: 'HcpUserShow',
            component: () => import('@/views/hcps/show'),
            meta: {
              title: 'HCP用户详情',
              activeMenu: '/hcp-users/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'HcpUserEdit',
            component: () => import('@/views/hcps/edit'),
            meta: {
              title: '编辑HCP用户',
              activeMenu: '/hcp-users/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/territories',
        name: 'Territories',
        component: () => import('@/views/territories/index'),
        redirect: '/territories/list?page=1',
        meta: {
          title: '岗位',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'TerritoriesList',
            component: () => import('@/views/territories/list'),
            meta: {
              title: '岗位',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'TerritorieNew',
            component: () => import('@/views/territories/new'),
            meta: {
              title: '添加岗位',
              activeMenu: '/territories/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id',
            name: 'TerritorieShow',
            component: () => import('@/views/territories/show'),
            meta: {
              title: '岗位详情',
              activeMenu: '/territories/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'TerritorieEdit',
            component: () => import('@/views/territories/edit'),
            meta: {
              title: '编辑岗位',
              activeMenu: '/territories/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      }
    ]
  },

  {
    path: '/office-accounts',
    component: Layout,
    name: 'OfficeAccounts',
    meta: {
      title: '服务号',
      icon: 'wechat',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: '/wechat-accounts',
        name: 'WechatAccounts',
        component: () => import('@/views/wechat-accounts/index'),
        redirect: '/wechat-accounts/list?page=1',
        meta: {
          title: '微信账号',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'WechatAccountsList',
            component: () => import('@/views/wechat-accounts/list'),
            meta: {
              title: '微信账号',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'list/:id',
            name: 'WechatAccountShow',
            component: () => import('@/views/wechat-accounts/show'),
            meta: {
              title: '账号详情',
              activeMenu: '/wechat-accounts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'WechatAccountEdit',
            component: () => import('@/views/wechat-accounts/edit'),
            meta: {
              title: '编辑账号',
              activeMenu: '/wechat-accounts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/reply-messages',
        name: 'ReplyMessages',
        component: () => import('@/views/reply-messages/index'),
        redirect: '/reply-messages/list?page=1',
        meta: {
          title: '回复图文',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'ReplyMessagesList',
            component: () => import('@/views/reply-messages/list'),
            meta: {
              title: '回复图文',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'ReplyMessageNew',
            component: () => import('@/views/reply-messages/new'),
            meta: {
              title: '添加回复图文',
              activeMenu: '/reply-messages/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'ReplyMessageEdit',
            component: () => import('@/views/reply-messages/edit'),
            meta: {
              title: '编辑回复图文',
              activeMenu: '/reply-messages/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/qrcodes',
        name: 'Qrcodes',
        component: () => import('@/views/qrcodes/index'),
        redirect: '/qrcodes/list?page=1',
        meta: {
          title: '二维码',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'QrcodesList',
            component: () => import('@/views/qrcodes/list'),
            meta: {
              title: '二维码',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'QrcodeNew',
            component: () => import('@/views/qrcodes/new'),
            meta: {
              title: '新建二维码',
              activeMenu: '/qrcodes/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id',
            name: 'QrcodeShow',
            component: () => import('@/views/qrcodes/show'),
            meta: {
              title: '扫码详情',
              activeMenu: '/qrcodes/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'QrcodeEdit',
            component: () => import('@/views/qrcodes/edit'),
            meta: {
              title: '编辑二维码',
              activeMenu: '/qrcodes/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/wechat-messages',
        name: 'WechatMessages',
        component: () => import('@/views/wechat-messages/index'),
        redirect: '/wechat-messages/list?page=1',
        meta: {
          title: '微信消息',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'WechatMessagesList',
            component: () => import('@/views/wechat-messages/list'),
            meta: {
              title: '微信消息',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          }
        ]
      }
    ]
  },

  {
    path: '/all-meetings',
    component: Layout,
    name: 'AllMeetings',
    meta: {
      title: '会议',
      icon: 'meetings',
      breadcrumb: false,
      roles: ['SuperAdmin', 'MeetingEditor']
    },
    children: [
      {
        path: '/meetings',
        name: 'Meetings',
        component: () => import('@/views/meetings/index'),
        redirect: '/meetings/list?page=1',
        meta: {
          title: '会议列表',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'MeetingsList',
            component: () => import('@/views/meetings/list'),
            meta: {
              title: '会议',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'MeetingNew',
            component: () => import('@/views/meetings/new'),
            meta: {
              title: '新建会议',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id',
            name: 'MeetingShow',
            component: () => import('@/views/meetings/show'),
            meta: {
              title: '会议详情',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'MeetingEdit',
            component: () => import('@/views/meetings/edit'),
            meta: {
              title: '编辑会议',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/notes',
            name: 'MeetingNotesList',
            component: () => import('@/views/meetings/notes/list'),
            meta: {
              title: '小纸条',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/invite/new',
            name: 'MeetingInviteNew',
            component: () => import('@/views/meetings/invite/new'),
            meta: {
              title: '添加邀请',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/invite/:inviteId/edit',
            name: 'MeetingInviteEdit',
            component: () => import('@/views/meetings/invite/edit'),
            meta: {
              title: '编辑邀请',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/schedule/new',
            name: 'MeetingScheduleNew',
            component: () => import('@/views/meetings/schedule/new'),
            meta: {
              title: '添加医生行程',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/schedule/:scheduleId/edit',
            name: 'MeetingScheduleEdit',
            component: () => import('@/views/meetings/schedule/edit'),
            meta: {
              title: '编辑医生行程',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/schedule/:scheduleId',
            name: 'MeetingScheduleShow',
            component: () => import('@/views/meetings/schedule/show'),
            meta: {
              title: '查看医生行程',
              activeMenu: '/meetings/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/offline-meetings',
        name: 'OfflineMeetings',
        component: () => import('@/views/offline-meetings/index'),
        redirect: '/offline-meetings/list?page=1',
        meta: {
          title: '会议列表',
          roles: ['SuperAdmin', 'MeetingEditor']
        },
        children: [
          {
            path: 'list',
            name: 'OfflineMeetingsList',
            component: () => import('@/views/offline-meetings/list'),
            meta: {
              title: '线下会议',
              breadcrumb: false,
              roles: ['SuperAdmin', 'MeetingEditor']
            }
          },
          {
            path: 'new',
            name: 'OfflineMeetingNew',
            component: () => import('@/views/offline-meetings/new'),
            meta: {
              title: '新建会议',
              activeMenu: '/offline-meetings/list',
              roles: ['SuperAdmin', 'MeetingEditor']
            },
            hidden: true
          },
          {
            path: 'list/:id',
            name: 'OfflineMeetingShow',
            component: () => import('@/views/offline-meetings/show'),
            meta: {
              title: '会议详情',
              activeMenu: '/offline-meetings/list',
              roles: ['SuperAdmin', 'MeetingEditor']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'OfflineMeetingEdit',
            component: () => import('@/views/offline-meetings/edit'),
            meta: {
              title: '编辑会议',
              activeMenu: '/offline-meetings/list',
              roles: ['SuperAdmin', 'MeetingEditor']
            },
            hidden: true
          },
          {
            path: 'list/:id/invite/new',
            name: 'OfflineMeetingInviteNew',
            component: () => import('@/views/meetings/invite/new'),
            meta: {
              title: '添加邀请',
              activeMenu: '/offline-meetings/list',
              roles: ['SuperAdmin', 'MeetingEditor']
            },
            hidden: true
          },
          {
            path: 'list/:id/invite/:inviteId/edit',
            name: 'OfflineMeetingInviteEdit',
            component: () => import('@/views/meetings/invite/edit'),
            meta: {
              title: '编辑邀请',
              activeMenu: '/offline-meetings/list',
              roles: ['SuperAdmin', 'MeetingEditor']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/live-broadcasts',
        name: 'LiveBroadcasts',
        component: () => import('@/views/live-broadcasts/index'),
        redirect: '/live-broadcasts/list?page=1',
        meta: {
          title: '直播列表',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'LiveBroadcastsList',
            component: () => import('@/views/live-broadcasts/list'),
            meta: {
              title: '直播',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'LiveBroadcastNew',
            component: () => import('@/views/live-broadcasts/new'),
            meta: {
              title: '添加直播',
              activeMenu: '/live-broadcasts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id',
            name: 'LiveBroadcastShow',
            component: () => import('@/views/live-broadcasts/show'),
            meta: {
              title: '直播详情',
              activeMenu: '/live-broadcasts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          // {
          //   path: 'list/:id/reservation',
          //   name: 'LiveBroadcastReservation',
          //   component: () => import('@/views/live-broadcasts/reservation'),
          //   meta: {
          //     title: '预约直播记录',
          //     activeMenu: '/live-broadcasts/list',
          //     roles: ['SuperAdmin']
          //   },
          //   hidden: true
          // },
          {
            path: 'list/:id/records',
            name: 'LiveBroadcastRecords',
            component: () => import('@/views/live-broadcasts/records'),
            meta: {
              title: '直播记录',
              activeMenu: '/live-broadcasts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'LiveBroadcastEdit',
            component: () => import('@/views/live-broadcasts/edit'),
            meta: {
              title: '编辑直播',
              activeMenu: '/live-broadcasts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/surveys',
        name: 'Surveys',
        component: () => import('@/views/surveys/index'),
        redirect: '/surveys/list?page=1',
        meta: {
          title: '问卷列表',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'SurveysList',
            component: () => import('@/views/surveys/list'),
            meta: {
              title: '问卷',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'SurveysNew',
            component: () => import('@/views/surveys/new'),
            meta: {
              title: '添加问卷',
              activeMenu: '/surveys/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'SurveysEdit',
            component: () => import('@/views/surveys/edit'),
            meta: {
              title: '编辑问卷',
              activeMenu: '/surveys/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id/questions',
            name: 'SurveysQuestions',
            component: () => import('@/views/surveys/questions'),
            meta: {
              title: '设置题目',
              activeMenu: '/surveys/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      }
    ]
  },

  {
    path: '/content',
    component: Layout,
    name: 'Content',
    meta: {
      title: '内容',
      icon: 'documentation',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: '/articles-category',
        name: 'ArticlesCategory',
        component: () => import('@/views/articles-category/index'),
        redirect: '/articles-category/list',
        meta: {
          title: '文章分类',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'ArticlesCategoryList',
            component: () => import('@/views/articles-category/list'),
            meta: {
              title: '文章分类',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'ArticlesCategoryNew',
            component: () => import('@/views/articles-category/new'),
            meta: {
              title: '添加分类',
              activeMenu: '/articles-category/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'ArticlesCategoryEdit',
            component: () => import('@/views/articles-category/edit'),
            meta: {
              title: '编辑分类',
              activeMenu: '/articles-category/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/articles',
        name: 'Articles',
        component: () => import('@/views/articles/index'),
        redirect: '/articles/list?page=1',
        meta: {
          title: '文章',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'ArticlesList',
            component: () => import('@/views/articles/list'),
            meta: {
              title: '文章',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'ArticleNew',
            component: () => import('@/views/articles/new'),
            meta: {
              title: '添加文章',
              activeMenu: '/articles/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'ArticleEdit',
            component: () => import('@/views/articles/edit'),
            meta: {
              title: '编辑文章',
              activeMenu: '/articles/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      }
    ]
  },

  {
    path: '/tweets-tasks',
    component: Layout,
    name: 'TweetsTasks',
    meta: {
      title: '推送',
      icon: 'guide',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: '/tweets',
        component: () => import('@/views/tweets/index'),
        redirect: '/tweets/list?page=1',
        name: 'Tweets',
        meta: {
          title: '内容推送',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'TweetsList',
            component: () => import('@/views/tweets/list'),
            meta: {
              title: '内容推送',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'TweetNew',
            component: () => import('@/views/tweets/new'),
            meta: {
              title: '新建内容推送',
              activeMenu: '/tweets/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'TweetEdit',
            component: () => import('@/views/tweets/edit'),
            meta: {
              title: '编辑内容推送',
              activeMenu: '/tweets/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/template-msgs',
        component: () => import('@/views/template-msgs/index'),
        redirect: '/template-msgs/list?page=1',
        name: 'TweetsTemplateMsgs',
        meta: {
          title: '模板消息推送',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'TweetsTemplateMsgsList',
            component: () => import('@/views/template-msgs/list'),
            meta: {
              title: '模板消息推送',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'TweetsTemplateMsgsNew',
            component: () => import('@/views/template-msgs/new'),
            meta: {
              title: '新建模板消息推送',
              activeMenu: '/template-msgs/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'TweetsTemplateMsgsEdit',
            component: () => import('@/views/template-msgs/edit'),
            meta: {
              title: '编辑模板消息推送',
              activeMenu: '/template-msgs/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: '/materials',
        component: () => import('@/views/materials/index'),
        redirect: '/materials/list?page=1',
        name: 'Materials',
        meta: {
          title: '微信素材',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'MaterialsList',
            component: () => import('@/views/materials/list'),
            meta: {
              title: '微信素材',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'MaterialNew',
            component: () => import('@/views/materials/new'),
            meta: {
              title: '新建微信素材',
              activeMenu: '/materials/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'list/:id',
            name: 'MaterialShow',
            component: () => import('@/views/materials/show'),
            meta: {
              title: '微信素材详情',
              activeMenu: '/materials/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'MaterialEdit',
            component: () => import('@/views/materials/edit'),
            meta: {
              title: '编辑微信素材',
              activeMenu: '/materials/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      }
    ]
  },

  {
    path: '/products',
    component: Layout,
    name: 'Products',
    meta: {
      title: '产品',
      icon: 'brand',
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: 'list',
        name: 'ProductsList',
        component: () => import('@/views/products/list'),
        meta: {
          title: '产品',
          breadcrumb: false,
          roles: ['SuperAdmin']
        }
      },
      {
        path: 'new',
        name: 'ProductNew',
        component: () => import('@/views/products/new'),
        meta: {
          title: '添加产品',
          activeMenu: '/products/list',
          roles: ['SuperAdmin']
        },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'ProductEdit',
        component: () => import('@/views/products/edit'),
        meta: {
          title: '编辑产品',
          activeMenu: '/products/list',
          roles: ['SuperAdmin']
        },
        hidden: true
      }
    ]
  },

  {
    path: '/charts',
    component: Layout,
    meta: {
      title: '报表',
      icon: 'chart',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: 'daily',
        name: 'DailyStatistics',
        component: () => import('@/views/charts/daily'),
        meta: {
          title: '用户日报表',
          roles: ['SuperAdmin']
        }
      },
      {
        path: 'monthly',
        name: 'MonthlyStatistics',
        component: () => import('@/views/charts/monthly'),
        meta: {
          title: '用户月报表',
          roles: ['SuperAdmin']
        }
      },
      {
        path: 'distribution',
        name: 'DistributionStatistics',
        component: () => import('@/views/charts/distribution'),
        meta: {
          title: '用户覆盖表',
          roles: ['SuperAdmin']
        }
      },
      {
        path: 'wechat-menu',
        name: 'WechatMenuStatistics',
        component: () => import('@/views/charts/wechat-menu'),
        meta: {
          title: '微信菜单使用',
          roles: ['SuperAdmin']
        }
      }
    ]
  },

  {
    path: '/logs',
    component: Layout,
    meta: {
      title: '日志',
      icon: 'list',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: 'operations',
        name: 'OperationsLogs',
        component: () => import('@/views/logs/operations'),
        meta: {
          title: '后台操作日志',
          roles: ['SuperAdmin']
        }
      },
      {
        path: 'pageviews',
        name: 'PageviewLogs',
        component: () => import('@/views/logs/pageviews'),
        meta: {
          title: '页面浏览日志',
          roles: ['SuperAdmin']
        }
      }
      // {
      //   path: 'tweets',
      //   name: 'TweetsLogs',
      //   component: () => import('@/views/logs/tweets'),
      //   meta: {
      //     title: '推送任务执行日志',
      //     roles: ['SuperAdmin']
      //   }
      // },
      // {
      //   path: 'materials',
      //   name: 'MaterialsLogs',
      //   component: () => import('@/views/logs/materials'),
      //   meta: {
      //     title: '模板消息推送日志',
      //     roles: ['SuperAdmin']
      //   }
      // }
    ]
  },

  {
    path: '/setting',
    component: Layout,
    name: 'Setting',
    meta: {
      title: '设置',
      icon: 'setting',
      breadcrumb: false,
      roles: ['SuperAdmin']
    },
    children: [
      {
        path: 'accounts',
        name: 'Accounts',
        component: () => import('@/views/accounts/index'),
        redirect: '/setting/accounts/list',
        meta: {
          title: '管理员账号',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'AccountsList',
            component: () => import('@/views/accounts/list'),
            meta: {
              title: '管理员账号',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'AccountNew',
            component: () => import('@/views/accounts/new'),
            meta: {
              title: '添加管理员账号',
              activeMenu: '/setting/accounts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'AccountEdit',
            component: () => import('@/views/accounts/edit'),
            meta: {
              title: '编辑管理员账号',
              activeMenu: '/setting/accounts/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: 'roles',
        name: 'RolesSetting',
        component: () => import('@/views/roles/index'),
        redirect: '/setting/roles/list',
        meta: {
          title: '角色管理',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'RolesSettingList',
            component: () => import('@/views/roles/list'),
            meta: {
              title: '角色管理',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'RolesSettingNew',
            component: () => import('@/views/roles/new'),
            meta: {
              title: '添加角色',
              activeMenu: '/setting/roles/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'RolesSettingEdit',
            component: () => import('@/views/roles/edit'),
            meta: {
              title: '编辑角色',
              activeMenu: '/setting/roles/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: 'user-group',
        name: 'UserGroup',
        component: () => import('@/views/user-group/index'),
        redirect: '/setting/user-group/list',
        meta: {
          title: '用户群组',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'UserGroupList',
            component: () => import('@/views/user-group/list'),
            meta: {
              title: '用户群组',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'UserGroupNew',
            component: () => import('@/views/user-group/new'),
            meta: {
              title: '添加用户群组',
              activeMenu: '/setting/user-group/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'UserGroupEdit',
            component: () => import('@/views/user-group/edit'),
            meta: {
              title: '群组下相关菜单',
              activeMenu: '/setting/user-group/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: 'menu',
        name: 'MenuSetting',
        component: () => import('@/views/menu/index'),
        redirect: '/setting/menu/list',
        meta: {
          title: '公众号菜单',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'MenuSettingList',
            component: () => import('@/views/menu/list'),
            meta: {
              title: '公众号菜单',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'MenuSettingNew',
            component: () => import('@/views/menu/new'),
            meta: {
              title: '添加菜单',
              activeMenu: '/setting/menu/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'MenuSettingEdit',
            component: () => import('@/views/menu/edit'),
            meta: {
              title: '编辑菜单',
              activeMenu: '/setting/menu/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      // {
      //   path: 'tasetting',
      //   name: 'TaSetting',
      //   component: () => import('@/views/tasetting/index'),
      //   redirect: '/setting/tasetting/list',
      //   meta: {
      //     title: 'TA列表',
      //     roles: ['SuperAdmin']
      //   },
      //   children: [
      //     {
      //       path: 'list',
      //       name: 'TaSettingList',
      //       component: () => import('@/views/tasetting/list'),
      //       meta: {
      //         title: 'TA列表',
      //         breadcrumb: false,
      //         roles: ['SuperAdmin']
      //       }
      //     },
      //     {
      //       path: 'new',
      //       name: 'TaSettingNew',
      //       component: () => import('@/views/tasetting/new'),
      //       meta: {
      //         title: '添加TA',
      //         activeMenu: '/setting/tasetting/list',
      //         roles: ['SuperAdmin']
      //       },
      //       hidden: true
      //     },
      //     {
      //       path: 'edit/:id',
      //       name: 'TaSettingEdit',
      //       component: () => import('@/views/tasetting/edit'),
      //       meta: {
      //         title: '编辑TA',
      //         activeMenu: '/setting/tasetting/list',
      //         roles: ['SuperAdmin']
      //       },
      //       hidden: true
      //     }
      //   ]
      // },
      // {
      //   path: 'busetting',
      //   name: 'BuSetting',
      //   component: () => import('@/views/busetting/index'),
      //   redirect: '/setting/busetting/list',
      //   meta: {
      //     title: 'BU列表',
      //     roles: ['SuperAdmin']
      //   },
      //   children: [
      //     {
      //       path: 'list',
      //       name: 'BuSettingList',
      //       component: () => import('@/views/busetting/list'),
      //       meta: {
      //         title: 'BU列表',
      //         breadcrumb: false,
      //         roles: ['SuperAdmin']
      //       }
      //     },
      //     {
      //       path: 'new',
      //       name: 'BuSettingNew',
      //       component: () => import('@/views/busetting/new'),
      //       meta: {
      //         title: '添加BU',
      //         activeMenu: '/setting/busetting/list',
      //         roles: ['SuperAdmin']
      //       },
      //       hidden: true
      //     },
      //     {
      //       path: 'edit/:id',
      //       name: 'BuSettingEdit',
      //       component: () => import('@/views/busetting/edit'),
      //       meta: {
      //         title: '编辑BU',
      //         activeMenu: '/setting/busetting/list',
      //         roles: ['SuperAdmin']
      //       },
      //       hidden: true
      //     }
      //   ]
      // },
      {
        path: 'provinces',
        name: 'Provinces',
        component: () => import('@/views/provinces/index'),
        redirect: '/setting/provinces/list',
        meta: {
          title: '省份',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'ProvincesList',
            component: () => import('@/views/provinces/list'),
            meta: {
              title: '省份',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'ProvinceNew',
            component: () => import('@/views/provinces/new'),
            meta: {
              title: '添加省份',
              activeMenu: '/setting/provinces/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'ProvinceEdit',
            component: () => import('@/views/provinces/edit'),
            meta: {
              title: '编辑省份',
              activeMenu: '/setting/provinces/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: 'cities',
        name: 'Cities',
        component: () => import('@/views/cities/index'),
        redirect: '/setting/cities/list',
        meta: {
          title: '城市',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'CitiesList',
            component: () => import('@/views/cities/list'),
            meta: {
              title: '城市',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'CityNew',
            component: () => import('@/views/cities/new'),
            meta: {
              title: '添加城市',
              activeMenu: '/setting/cities/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'CityEdit',
            component: () => import('@/views/cities/edit'),
            meta: {
              title: '编辑城市',
              activeMenu: '/setting/cities/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: 'hospitals',
        name: 'HospitalSetting',
        component: () => import('@/views/hospitals/index'),
        redirect: '/setting/hospitals/list?page=1',
        meta: {
          title: '医院',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'HospitalSettingList',
            component: () => import('@/views/hospitals/list'),
            meta: {
              title: '医院',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'HospitalSettingNew',
            component: () => import('@/views/hospitals/new'),
            meta: {
              title: '添加医院',
              activeMenu: '/setting/hospitals/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'HospitalSettingEdit',
            component: () => import('@/views/hospitals/edit'),
            meta: {
              title: '编辑医院',
              activeMenu: '/setting/hospitals/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      },
      {
        path: 'departments',
        name: 'DepartmentSetting',
        component: () => import('@/views/departments/index'),
        redirect: '/setting/departments/list',
        meta: {
          title: '科室',
          roles: ['SuperAdmin']
        },
        children: [
          {
            path: 'list',
            name: 'DepartmentSettingList',
            component: () => import('@/views/departments/list'),
            meta: {
              title: '科室',
              breadcrumb: false,
              roles: ['SuperAdmin']
            }
          },
          {
            path: 'new',
            name: 'DepartmentSettingNew',
            component: () => import('@/views/departments/new'),
            meta: {
              title: '添加科室',
              activeMenu: '/setting/departments/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          },
          {
            path: 'edit/:id',
            name: 'DepartmentSettingEdit',
            component: () => import('@/views/departments/edit'),
            meta: {
              title: '编辑科室',
              activeMenu: '/setting/departments/list',
              roles: ['SuperAdmin']
            },
            hidden: true
          }
        ]
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // base: process.env.NODE_ENV === 'production'
  //   ? '/admin/'
  //   : '/',
  base: '/admin/',
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
